﻿
namespace SuperMarieApi.App.Controllers.Tool.Extensions
{
    using System;

    public static class DecimalExte
    {
        /// <summary>
        /// 价格按数量分摊（合并首重快递价格计算专用）
        /// </summary>
        /// <param name="s"></param>
        /// <returns></returns>
        public static decimal[] PostFeeShare(this decimal s,int n)
        {
            decimal[] Price = new decimal[n];
            decimal yu = 0;
            decimal zheng = 0;
            if (n > 0)
            {
                // 66/10
                zheng =Math.Floor( Math.Floor(s) / n);
                yu = s - zheng * n;
                for (int i = 0; i < n; i++)
                {
                    if (i == 0)
                    {
                        Price[i] =  zheng + yu ;
                    }
                    else
                    {
                        Price[i] = zheng;
                    }
                }
            }
            return Price;
        }
    }
}
